<template>
    <div id="injcet">
        <div class="input-box">
            <p>父组件利用provide给子组件传值</p>
            <input type="text" v-model="acceptVal">
            <div>---------------------------------------------</div>
            <p>父组件接收子组件传过来的值</p>
            <input type="text" v-model="sunzidezhi">
            <div>---------------------------------------------</div>
            <textarea v-model="name"></textarea>
        </div>
        <sunzi @toInjectSon="getValFromSunzi"></sunzi>
    </div>
</template>
<script lang="ts">
import { inject, Ref } from 'vue'
import sunzi from './sunzi.vue'
export default {
    name: 'injcet',
    components: {
        sunzi,
    },
    data() {
        return {
            sunzidezhi: '',
        }
    },
    setup() {
      const acceptVal:any = inject<Ref<number>>('prop1')
      const name:any = inject('prop3');
      return {
          acceptVal,
          name,
      }
    },
    methods: {
        getValFromSunzi(val){
            this.sunzidezhi = val;
        }
    }
}
</script>